/** * HTMLResponder - provides rendering and sending Document as response. * * Copyright (c) 2002 * Marty Phelan, All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package com.taursys.servlet.respond; import com.taursys.servlet.ServletForm; import com.taursys.xml.event.RenderEvent; import com.taursys.xml.event.RenderDispatcher; /** * HTMLResponder provides rendering and sending Document as response. * @author Marty Phelan * @version 1.0 */ public class HTMLResponder extends ContentResponder { /** * Constructs a new HTMLResponder and sets contentType to text/html. */ public HTMLResponder() { setContentType("text/html"); } /** * Render the Components to the Document it as the response. * This method first invokes the ServletForm's RenderDispatcher to notify * Components to render themselves to the Document. It then sets the * response's contentType. Finally, it uses the DocumentAdapter to * render the Document to the response's PrintWriter. * @throws Exception generated by Components during rendering. */ public void respond() throws Exception { ((RenderDispatcher)getServletForm().getDispatcher( RenderEvent.class.getName())).dispatch(); getServletForm().getResponse().setContentType(getContentType()); getServletForm().getDocumentAdapter().write( getServletForm().getResponse().getWriter()); } }